﻿@model System.Collections.IList

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_BaseLayout.cshtml";
    var X = Html.X();
}

<h2>Index</h2>

@section example
{
    @(X.Viewport()
        .Layout(LayoutType.Border)
        .Items(
                X.Panel()
                  .Region(Region.Center)
                  .Margins("5 5 5 5")
                  .Items(
                        X.GridPanel()
                            .ID("gpAccountInfo")
                            .Region(Region.Center)
                            .Title("用户管理")
                            .Store(X.Store()
                                    .Model(X.Model()
                                        .Fields(
                                                    new ModelField("ID", ModelFieldType.String),
                                                    new ModelField("UserName", ModelFieldType.String),
                                                    new ModelField("NickName", ModelFieldType.String),
                                                    new ModelField("Email", ModelFieldType.String),
                                                    new ModelField("AddDate", ModelFieldType.String),
                                                    new ModelField("IsDeleted", ModelFieldType.Boolean)
                                                )
                                            )
                                    .DataSource(Model)
                                    )
                                    .ColumnModel
                                    (
                                                X.RowNumbererColumn(),
                                                //X.Column().Text("ID").DataIndex("ID").Flex(1),
                                                X.Column().Text("UserName").DataIndex("UserName").Flex(1),
                                                X.Column().Text("NickName").DataIndex("NickName"),
                                                X.Column().Text("Email").DataIndex("Email").Flex(1),
                                                X.Column().Text("IsDeleted").DataIndex("IsDeleted"),
                                                X.Column().Text("AddDate").DataIndex("AddDate")
                                    )
                            .TopBar(
                                Html.X().Toolbar()
                                    .Items(
                                Html.X().Button()
                                    .Text("新增")
                                    .Icon(Icon.Add)
                                    .DirectEvents(de => {
                                        de.Click.Url = Url.Action("AddClick");
                                        }),

                                    Html.X().Button()
                                        .Text("修改")
                                        .Icon(Icon.Accept)
                                        .Handler("deleteSelected(this.up('grid'));"),

                                        Html.X().Button()
                                            .Text("停用")
                                            .Icon(Icon.Accept)
                                            .Handler("deleteSelected(this.up('grid'));"),

                                Html.X().Button()
                                    .Text("直接删除")
                                    .Icon(Icon.Delete)
                                    .Handler("deleteSelected(this.up('grid'));"),

                                Html.X().ToolbarFill(),

                                Html.X().Button()
                                    .Text("浏览")
                                    .Icon(Icon.Find)
                                    .Handler("selectRecord(this.up('grid'), 'Government Motors Corporation');"),

                                Html.X().Button()
                                    .Text("导出")
                                    .Icon(Icon.Disk)
                                    .DirectEvents(de =>
                                    {
                                        de.Click.Url = Url.Action("Sync");
                                        de.Click.ExtraParams.Add(new Parameter
                                        {
                                            Name = "data",
                                            Value = "this.up('grid').store.getChangedData()",
                                            Mode = ParameterMode.Raw,
                                            Encode = true
                                        });
                                    }),
                                Html.X().Button()
                                    .Text("刷新")
                                    .Icon(Icon.Find)
                                    .Handler("selectRecord(this.up('grid'), 'Government Motors Corporation');")
                            )
                    )
                         )
               )
)
}